home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / c / amiexpress / source / ae / code / ax3.00 / displayfilelist.c < prev    next >
Encoding:
C/C++ Source or Header  |  1980-01-03  |  3.0 KB  |  137 lines

  1. #include "bbs.h"
  2.  
  3. static int DisplayIt(char *fname)
  4. {
  5.  int MoreStat,stat,Color = 0;
  6.  char str[200];
  7.  FILE *fp;
  8.  
  9.  if(!(fp=fopen(fname,"r"))) {
  10.        MyError(4);                  //(RTS) FileListError();
  11.        return(SUCCESS);
  12.     }
  13.  
  14. /* We should check for the file in ram: if there, show it, if not, copy it */
  15.  
  16.      while(fgets(str,80,fp)!=NULL)
  17.      {
  18.          str[81]='\0';
  19.         if(str[strlen(str)-1]=='\n') {
  20.          if(gnsflag!=1)            LineCount++;
  21.             strcat(str,"\r");
  22.         }
  23.  
  24.      if(Color==1)
  25.           AEPutStr("");
  26.           AEPutStr(str);
  27.  
  28.         if(SCheckInput())    {
  29.          stat=ReadChar(1L);
  30.             if(stat<0) {
  31.              fclose(fp);
  32.              return(stat);
  33.          }
  34.             switch(stat) {
  35.             case '\023': /* Pause */
  36.                 stat=ReadChar(KEYBOARD_TIMEOUT);
  37.                 if(stat<0)    {
  38.                  fclose(fp);
  39.                   return(NO_CARRIER);
  40.              }
  41.                 break;
  42.             case '\003': /* ^C */
  43.              fclose(fp);
  44.                 AEPutStr("**Break\r\n\r\n");
  45.                 return(FAILURE);
  46.             }
  47.         }
  48.      MoreStat=FlagPause(0);
  49.         if(MoreStat<0) {
  50.          fclose(fp);
  51.          return(MoreStat);
  52.      }
  53.     } 
  54.  fclose(fp);
  55.  return(SUCCESS);
  56. }
  57.  
  58. int DisplayFileList(void)
  59. {
  60.  int stat,stat2,FLLoop;
  61.  char str[81],ray[200];
  62.  char tempfile[256];
  63.  int fcopy = FALSE;
  64.  
  65.  gnsflag=LineCount=0;
  66.  
  67.  AEPutStr("\r\n");
  68.  if(MaxDirs==0) {
  69.         MyError(5); //Sorry();
  70.         return(FAILURE);
  71.     }
  72.  
  73.  stat2=CommandSplit();
  74.  if(stat2>1)
  75.         stat=GetDirSpan(Command[1]);
  76.  else {
  77.         sprintf(GSTR1,"%sFileHelp",Screen_Location);
  78.         if(!(stat=ChecktoDisplay(GSTR1,GSTR3,0,0)))
  79.             UnAvailNotice(GSTR3,GSTR1);
  80.         stat=GetDirSpan("\0");
  81.     }
  82.  
  83.  if(stat==FAILURE)  return(SUCCESS);
  84.  
  85.  gnsflag=CheckForNS(MAINMENU_Li);
  86.  
  87.  FLLoop=StartDir;
  88.  while(FLLoop<=DirScan) {
  89.         strcpy(str,Conference_Location);
  90.         if(DirScan!=(-1)) {
  91.          if(FLLoop == MaxDirs) {    /* at upload dir */
  92.             strcat(str,"DIR");
  93.                 sprintf(ray,"%d",FLLoop);
  94.                strcat(str,ray);
  95.             sprintf(ray,"Scanning directory %d\r\n",FLLoop);
  96.              AEPutStr(ray);
  97.  
  98.             /* now copy to T: and use T: copy */
  99.             sprintf(tempfile,"T:tdir.%d",Cmds->AcLvl[LVL_NODE_NUMBER]);
  100.             if((FileCopy(str,tempfile))) {
  101.                  strcpy(str,tempfile);
  102.                  fcopy = TRUE;
  103.             }
  104.          } else {
  105.          strcat(str,"DIR");
  106.             sprintf(ray,"%d",FLLoop);
  107.             strcat(str,ray);
  108.          sprintf(ray,"Scanning directory %d\r\n",FLLoop);
  109.             AEPutStr(ray);
  110.         }
  111.         } else {
  112.             strcat(str,"hold/held");
  113.             AEPutStr("Scanning directory HOLD\r\n");
  114.         }
  115.         stat=FlagPause(1);
  116.         if(stat<0) {
  117.          if(fcopy)      DeleteFile(tempfile);  //(RTS)
  118.          return(stat);
  119.      }
  120.      stat = DisplayIt(str);
  121.      if(fcopy) {
  122.          DeleteFile(tempfile);  //(RTS)
  123.          fcopy = FALSE;
  124.      }
  125.      if(stat==FAILURE)       return(SUCCESS);
  126.      if(stat==NO_CARRIER)    return(NO_CARRIER);
  127.         if(stat==TIMEOUT)       return(stat);
  128.      //if(DirScan == MaxDirs)  return(stat);
  129.  
  130.         AEPutStr("\r\n");
  131.         FLLoop+=1;
  132.     }
  133.  if(fcopy)      DeleteFile(tempfile);  //(RTS)
  134.  return(SUCCESS);
  135. }
  136.  
  137.